package com.smartens.boit;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class Myservice extends Service {
    Handler handler=new Handler();
    private boolean b=true;

    @Override
    public void onCreate() {
        super.onCreate();

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        new Thread()
        {
            @Override
            public void run() {
                super.run();
                while (b) {
                    handler.post(new Runnable() {
                        @Override
                        public void run() {

                        }

                    });
                    try {
                        sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }.start();
        return super.onStartCommand(intent, flags, startId);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return new MyBinder();
    }
    class MyBinder extends Binder
    {
        public  Myservice getMyservice()
        {
            return  Myservice.this;
        }
    }
}
